﻿<UserControl x:Class="ModernUILogViewer.Content.ContentRegexSettings"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:view="clr-namespace:ModernUILogViewer.View"                
             xmlns:elem="clr-namespace:ModernUILogViewer.Elements"                
             xmlns:helper="clr-namespace:ModernUILogViewer.Elements.Helpers"
             xmlns:business="clr-namespace:ModernUILogViewer.Business"
             xmlns:validation="clr-namespace:ModernUILogViewer.Validation"
             xmlns:sys="clr-namespace:System.Globalization;assembly=mscorlib"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                             
             mc:Ignorable="d" 
             x:Name="Window"
             d:DesignHeight="350" d:DesignWidth="600">

    <UserControl.Triggers>
        <!--<EventTrigger RoutedEvent="helper:NotifierPanelHelper.ChildrenChanged">
            
        </EventTrigger>-->
    </UserControl.Triggers>

    <UserControl.Resources>

    </UserControl.Resources>

    <Grid HorizontalAlignment="Left" x:Name="grid" MinWidth="200" helper:NotifierPanelHelper.EnableNotifier="True">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="6*"></ColumnDefinition>
            <ColumnDefinition Width="2*"></ColumnDefinition>
            <ColumnDefinition Width="2*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <TextBlock x:Name="txtTooltip" Grid.ColumnSpan="3" HorizontalAlignment="Center">

        </TextBlock>
        <TextBlock Text="BEGINNING OF THE LINE (REG EXP)" Style="{StaticResource Heading2}" Margin="0,0,0,8" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" />
        <TextBox Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2">
            <TextBox.Text>
                <Binding Path="LineBeginningRegExp" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <validation:LineRegexValidation />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        <TextBlock Text="DATE (REG EXP)" Style="{StaticResource Heading2}" Margin="0,4,0,8"  Grid.Column="0" Grid.Row="3" />
        <TextBox IsEnabled="{Binding IncludeDateMatch}" Text="{Binding DateRegExp, Mode=TwoWay}"  Grid.Column="0" Grid.Row="4" />
        <TextBlock Text="GROUP MATCH" Style="{StaticResource Heading2}" Margin="0,4,0,8" Grid.Column="1" Grid.Row="3" />
        <xctk:IntegerUpDown IsEnabled="{Binding IncludeDateMatch}" Margin="{StaticResource DefaultLeftMargin}"  Value="{Binding DateGroupMatch, Mode=TwoWay}" Minimum="0" Maximum="5" Grid.Column="1" Grid.Row="4"  />
        <TextBlock Text="INCLUDE" Style="{StaticResource Heading2}" Margin="4,4,0,8" Grid.Column="2" Grid.Row="3" />
        <CheckBox IsChecked="{Binding IncludeDateMatch}" x:Name="datechkbox" Margin="{StaticResource DefaultTopLeftMargin}" HorizontalAlignment="Left" Grid.Column="2" Grid.Row="4" />
        <TextBlock Text="LEVEL (REG EXP)" Style="{StaticResource Heading2}" Margin="0,4,0,8"  Grid.Column="0" Grid.Row="5" />
        <TextBox IsEnabled="{Binding IncludeLevelMatch}" Text="{Binding LevelRegExp, Mode=TwoWay}"  Grid.Column="0" Grid.Row="6"  />        
        <TextBlock Text="GROUP MATCH" Style="{StaticResource Heading2}" Margin="0,4,0,8"  Grid.Column="1" Grid.Row="5" />
        <xctk:IntegerUpDown  IsEnabled="{Binding IncludeLevelMatch}" Margin="{StaticResource DefaultLeftMargin}"  Value="{Binding LevelGroupMatch, Mode=TwoWay}" Minimum="0" Maximum="5" Grid.Column="1" Grid.Row="6" />
        <TextBlock Text="INCLUDE" Style="{StaticResource Heading2}" Margin="4,4,0,8" Grid.Column="2" Grid.Row="5" />
        <CheckBox IsChecked="{Binding IncludeLevelMatch}" x:Name="levelchkbox" Margin="{StaticResource DefaultTopLeftMargin}" HorizontalAlignment="Left" Grid.Column="3" Grid.Row="6" />
        <TextBlock Text="DATE FORMAT" Style="{StaticResource Heading2}" Margin="0,4,0,8"  Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="2" />
        <TextBox IsEnabled="{Binding IncludeDateMatch}"  Text="{Binding DateFormat, Mode=TwoWay}"   Grid.Column="0" Grid.Row="8" Grid.ColumnSpan="2"  />
        <TextBlock Text="CULTURE" Style="{StaticResource Heading2}" Margin="0,4,0,8"  Grid.Column="2" Grid.Row="7" />
        <ComboBox IsEnabled="{Binding IncludeDateMatch}" ItemsSource="{Binding Source={StaticResource cultures}}" SelectedItem="{Binding SelectedCultureInfo, TargetNullValue='en-US'}" Grid.Row="8" Grid.Column="2" />

        <StackPanel Orientation="Horizontal" Grid.Row="9" Grid.ColumnSpan="2" Margin="0, 12, 0, 0">
            <Button x:Name="savebtn" IsEnabled="False" Content="Save" Command="{Binding Source={StaticResource settingsmanager}, Path=SaveRegexSettings}" CommandParameter="{Binding}" />
            <Button x:Name="reloadbtn"  IsEnabled="False" Content="Reload" Command="{Binding Source={StaticResource settingsmanager}, Path=ReloadRegexSettings}" CommandParameter="{Binding}" Margin="{StaticResource DefaultLeftMargin}" />
        </StackPanel>
    </Grid>

    <i:Interaction.Triggers>
        <!--<i:EventTrigger SourceObject="(helper:NotifierPanelHelper.ChildrenChanged)" >
            <ei:ChangePropertyAction TargetName="savebtn" PropertyName="IsEnabled" Value="True" />
            <ei:ChangePropertyAction TargetName="reloadbtn" PropertyName="IsEnabled" Value="True" />
        </i:EventTrigger>-->
        <!--<i:EventTrigger EventName="ChildrenChanged" SourceObject="{Binding ElementName=grid}">
            <ei:ChangePropertyAction TargetName="savebtn" PropertyName="IsEnabled" Value="True" />
            <ei:ChangePropertyAction TargetName="reloadbtn" PropertyName="IsEnabled" Value="True" />
        </i:EventTrigger>-->
        <i:EventTrigger EventName="ImportSettingsEventException" SourceObject="{Binding}">
            <i:InvokeCommandAction Command="{x:Static view:ViewCommands.ShowMessageBox}" CommandParameter="Invalid settings|Settings error" />
        </i:EventTrigger>
        <i:EventTrigger EventName="ExportSettingsSuccessfulEvent" SourceObject="{Binding}">
            <i:InvokeCommandAction Command="{x:Static view:ViewCommands.ShowMessageBox}" CommandParameter="Settings successfully exported|Settings" />
        </i:EventTrigger>
        <i:EventTrigger EventName="SettingsSaved" SourceObject="{StaticResource settingsmanager}">
            <ei:ChangePropertyAction TargetObject="{Binding ElementName=savebtn}" PropertyName="IsEnabled" Value="False" />
            <ei:ChangePropertyAction TargetObject="{Binding ElementName=reloadbtn}" PropertyName="IsEnabled" Value="False" />
        </i:EventTrigger>
        <i:EventTrigger EventName="SettingsReloaded" SourceObject="{StaticResource settingsmanager}">
            <ei:ChangePropertyAction TargetObject="{Binding ElementName=reloadbtn}" PropertyName="IsEnabled" Value="False" />
            <ei:ChangePropertyAction TargetObject="{Binding ElementName=savebtn}" PropertyName="IsEnabled" Value="False" />
        </i:EventTrigger>
        <helper:RoutedEventTrigger RoutedEvent="{x:Static helper:NotifierPanelHelper.ChildrenChangedEvent}">
            <ei:ChangePropertyAction TargetName="savebtn" PropertyName="IsEnabled" Value="True" />
            <ei:ChangePropertyAction TargetName="reloadbtn" PropertyName="IsEnabled" Value="True" />
        </helper:RoutedEventTrigger>

    </i:Interaction.Triggers>

</UserControl>
